package com.javasea.websocket.service;

import com.javasea.websocket.handler.Handler;
import com.javasea.websocket.handler.impl.*;
import com.javasea.websocket.utils.SpringContextHolder;

/**
 * @author: Ethan_Fung
 * @description: 处理器枚举，模板方法方式获取需要处理的handler
 * @date: 2019/10/31 15:08
 * @version: 1.0
 **/
public enum Action {
    LINK_OPEN {
        @Override
        public Handler getAction() {
            return SpringContextHolder.getBean(LinkOpenHandler.class);
        }
    },
    GET_TODO_NUM {
        @Override
        public Handler getAction() {
            return SpringContextHolder.getBean(GetTodoHandler.class);
        }
    },
    HEART_CHECK {
        @Override
        public Handler getAction() {
            return SpringContextHolder.getBean(HeartCheckHandler.class);
        }
    },
    LINK_CLOSE{
        @Override
        public Handler getAction() {
            return SpringContextHolder.getBean(LinkCloseHandler.class);
        }
    },
    FLOW_NOTIFY{
        @Override
        public Handler getAction() {
            return SpringContextHolder.getBean(FlowNotifyHandler.class);
        }
    };

    public abstract Handler getAction();
}
